<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/v2/console/common/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>十方天资官网后台管理系统</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="${path}/v2/console/css/base.css">
<link rel="stylesheet" href="${path}/v2/console/css/style.css">
<script src="${path}/v2/console/js/jquery-1.9.1.min.js"></script>
</head>
<body>
	<div id="wrapper">
		<div class="main">
			<div class="main-right">
				<div class="column-name">
					<h2>
						内容管理 > <b>编辑文章</b>
					</h2>
				</div>
				<div class="form">
					<form id="aform" name="aform" action="${pageContext.request.contextPath}/siteArticle/updateArticle.html" method="post">
						<input type="hidden" name="articleId" value="${obj.articleId }">
						<input type="hidden" name="nodeId" value="${obj.nodeId }">
						<div class="form-item">
							<div class="form-name">标题:</div>
							<div class="form-input">
								<input type="text" id="title" name="title" class="input" value="${obj.title }">
								<div class="clearfix"></div>
								<div class="form-error red"></div>
							</div>
						</div>
						<div class="form-item">
							<div class="form-name">副标题:</div>
							<div class="form-input">
								<input type="text" id="subtitle" name="subtitle" class="input" value="${obj.subtitle }">
								<div class="clearfix"></div>
								<div class="form-error red"></div>
							</div>
						</div>
						<div class="form-item">
							<div class="form-name">作者:</div>
							<div class="form-input">
								<input type="text" id="author" name="author" class="input" value="${obj.author }">
								<div class="clearfix"></div>
								<div class="form-error red"></div>
							</div>
						</div>
						<br/>
						<div class="form-item">
							<div class="form-name">文章内容：</div>
							<div class="form-input">
								<textarea name="content" id="content" class="input">${obj.content }</textarea>
							</div>
						</div>
						<div class="form-item" >
							<div class="form-name">是否推荐：</div>
							<div class="form-input">
								<select id="isRecom" name="isRecom" class="input">
									<option value="1" 
									<c:if test="${obj.isRecom == 1 }">selected="selected"</c:if>
									>是</option>
									<option value="0" 
									<c:if test="${obj.isRecom == 0 }">selected="selected"</c:if>
									>否</option>
								</select>
								<div class="clearfix"></div>
								<div class="form-msg hide" style="color: red;"></div>
							</div>
						</div>
						<input type="hidden" name="picLink" id="picLink" value="${obj.picLink }">
					</form>
					
					<form id="firstPicForm" onsubmit="return false;">
						<div class="form-item form-item01">
							<div class="form-name">标题图片<span style="color:red;"></span>：</div>
							<div class="form-input">
								<input type='text' id='textfield' class='input' /> 
								<input type="file" name="img" class="file input" id="fileField"  onchange="document.getElementById('textfield').value=this.value" />
    							<button class="btn-blue" onclick="uploadFirstImage()">上传图片</button>
    							<div class="clearfix"></div>
    							<div id="firstPic" class="form-img">
   									<c:if test="${not empty obj.picLink}">
    									<img src="${obj.picLink}" alt="">
	    							</c:if>
   									<c:if test="${empty obj.picLink}">
    									<img src="" alt="">
	    							</c:if>
    							</div>
							</div>
						</div>
					</form>
					<button type="button" class="btn w144" onclick="add()">保  存</button>
				</div>
			</div>
		</div>
	</div>
<script type="text/javascript"	src="${path}/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript">
KE.show({
	id : 'content',
	height:'500px',
	imageUploadJson : '${path}/siteArticle/uploadDescImage.html', //'${path}/kindeditor/jsp/upload_json.jsp',
	allowFileManager : true,
	afterCreate : function(id) {
		KE.event.ctrl(document, 13, function() {
			KE.util.setData(id);
		});
	}
});


function uploadFirstImage(){
	var formData = new FormData($("#firstPicForm")[0]);
	$.ajax({
		type : "post",
		url : "uploadFirstImage.html",
		dataType : "json",
		data : formData,
		async : false,
		cache: false,
        contentType: false,
        processData: false,
		success : function(data) {
			if(data.ajax_status == "ajax_status_success"){
				$("#firstPic").find("img").attr("src",data.targetPath);
				$("#picLink").val(data.picUrl);
				$("#firstPic").show();
			}else{
				alert(data.msg);
			}
			return false;
		},
		error : function(XMLHttpRequest, textStatus, errorThrown){
          alert("出错了！");
       }
	});
	return false;;
}

//提交
function add(){
	/* if($("#picLink").val().length == 0){
		alert("请上传标题图片");
		return false;
	} */
	$("#aform").submit();
}
</script>
</body>
</html>
